001 /*
002 * Copyright 2004 Niclas Hedhman.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.transit.monitor;
020
021 import java.net.URL;
022
023 /**
024 * Adapts connection events to logging messages.
025 *
026 * <p>
027 * The NetworkMonitor must be thread safe.
028 * </p>
029 *
030 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
031 * @version 1.0.1
032 * @see net.dpml.transit.monitor.Monitor
033 */
034 public class ConnectionMonitorAdapter extends AbstractAdapter
035 implements ConnectionMonitor
036 {
037 // ------------------------------------------------------------------------
038 // constructor
039 // ------------------------------------------------------------------------
040
041 /**
042 * Creation of a new adaptive connection monitor.
043 * @param adapter the adapter to assign to the monitor
044 */
045 public ConnectionMonitorAdapter( Adapter adapter )
046 {
047 super( adapter );
048 }
049
050 // ------------------------------------------------------------------------
051 // ConnectionMonitor
052 // ------------------------------------------------------------------------
053
054 /**
055 * Notify the monitor that a connection was opened.
056 * @param url the url on which the open connection was issued
057 */
058 public void connectionOpened( URL url )
059 {
060 if( getAdapter().isDebugEnabled() )
061 {
062 getAdapter().debug( "opened connection: " + url );
063 }
064 }
065
066 /**
067 * Notify the monitor that a connection was started.
068 * @param url the target connection
069 */
070 public void connectStarted( URL url )
071 {
072 }
073
074 /**
075 * Notify the monitor that a connection was completed.
076 * @param url the target connection
077 */
078 public void connectCompleted( URL url )
079 {
080 if( getAdapter().isDebugEnabled() )
081 {
082 getAdapter().debug( "closed connection: " + url );
083 }
084 }
085 }